/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.sd.entity;

import javax.validation.constraints.NotBlank;

import com.jeesite.modules.sd.common.constants.RecvConstant;
import com.jeesite.modules.sd.common.constants.RecvUppUnitEnum;
import org.hibernate.validator.constraints.Length;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 上级来文单位Entity
 * @author zhanchj
 * @version 2020-07-01
 */
@Table(name = "sd_upp_unit", alias = "a", columns = {
		@Column(name = "id", attrName = "id", label = "id", isPK = true),
		@Column(name = "unit_name", attrName = "unitName", label = "单位名称", queryType = QueryType.LIKE),
		@Column(name = "address", attrName = "address", label = "单位地址"),
		@Column(name = "unit_type", attrName = "unitType", label = "单位类型", comment = "单位类型（1保密局,2公安部,3其它单位）"),
}, orderBy = "a.id DESC"
)
public class UppUnit extends DataEntity<UppUnit> {

	private static final long serialVersionUID = 1L;
	/**
	 * 单位名称
	 */
	private String unitName;
	/**
	 * 单位地址
	 */
	private String address;
	/**
	 * 单位类型（1保密局,2公安部,3其它单位）
	 */
	private String unitType;


	public UppUnit() {
		this(null);
	}

	public UppUnit(String id) {
		super(id);
	}

	@NotBlank(message = "单位名称不能为空")
	@Length(min = 0, max = 100, message = "单位名称长度不能超过 100 个字符")
	public String getUnitName() {
		return unitName;
	}

	public void setUnitName(String unitName) {
		this.unitName = unitName;
	}

	/**
	 * 拼接单位名称和单位类型(用于前端)
	 * @return
	 */
	public String getUnitNameType() {
		String unitNameType = this.getUnitName() + "(";
		if (RecvUppUnitEnum.SECRET.getKey().equals(this.unitType)) {
			unitNameType += RecvUppUnitEnum.SECRET.getValue();
		} else if (RecvUppUnitEnum.MOPS.getKey().equals(this.unitType)) {
			unitNameType += RecvUppUnitEnum.MOPS.getValue();
		} else {
			unitNameType += RecvUppUnitEnum.OTHER.getValue();
		}
		return unitNameType + ")";
	}


	@Length(min = 0, max = 400, message = "单位地址长度不能超过 400 个字符")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	@Length(min=0, max=1, message="单位类型长度不能超过 1 个字符")
	public String getUnitType() {
		return unitType;
	}

	public void setUnitType(String unitType) {
		this.unitType = unitType;
	}
	
}